<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@page import="java.util.*"%>
<%@page import="weaver.file.FileUpload"%>
<%@page import="weaver.general.Util"%>
<%@page import="weaver.mobile.plugin.ecology.service.HrmResourceService"%>
<%@page import="weaver.hrm.User"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="com.weaver.formmodel.mobile.manager.MobileUserInit"%>

<%
    out.clearBuffer();

    request.setCharacterEncoding("UTF-8");
    
    FileUpload fu = new FileUpload(request);
    HrmResourceService hrs = new HrmResourceService();
    User user = MobileUserInit.getUser(request, response);
    if (user == null) {
        Map result = new HashMap();
        //未登录或登录超时
        result.put("error", "200001");
        JSONObject jo = (JSONObject) JSONObject.toJSON(result);
        out.println(jo);
        return;
    }
    
    String opt = Util.null2String(fu.getParameter("opt"));
    
    JSONObject result = new JSONObject();
    
    if("viewBlogUrl".equals(opt)) {
        result.put("status", "0");
        result.put("url", "");
        
        int viewBlogId = Util.getIntValue(Util.null2String(fu.getParameter("viewBlogId")));
        if(viewBlogId > 0) {
            result.put("status", "1");
            result.put("url", "/mobilemode/apps/e-cology/blog/appHomepage.jsp?viewBlogId=" + viewBlogId); //访问地址
            
            //微博总数
            int count = 0;
            RecordSet rs = new RecordSet();
            rs.executeQuery("select count(id) from blog_discuss where userid = ?", viewBlogId);
            if(rs.next()) {
            	count = rs.getInt(1);
            }
            result.put("count", String.valueOf(count));
        }
        
        out.println(result);
        return;
    }
%>
